package com.hzqy.web.vo.activity;

import java.io.Serializable;

public class LotteryRequestVo implements Serializable{
	private String url;// 接口地址
	private String action;// String Y 16 请求方名称 作为IP筛选
	private String userid;// String Y 24 用户iTV账号
	private int activityid;// Int Y 4 活动ID，由用户俱乐部提供给活动方
	private int awardlevel;// Int Y 4 奖项，默认为0
	private int vt;// Int Y 平台版本编号
	private String ts;// String Y 14 请求时间戳yyyyMMddHHmmss
	private String digest;// String Y 32
							// 摘要，HEX(MD5(action+userid+activityid+awardlevel+vt+ts))
	private String phone;// String N 11 用户手机号

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getAction() {
		return action;
	}

	public void setAction(String action) {
		this.action = action;
	}

	public String getUserid() {
		return userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	public int getActivityid() {
		return activityid;
	}

	public void setActivityid(int activityid) {
		this.activityid = activityid;
	}

	public int getAwardlevel() {
		return awardlevel;
	}

	public void setAwardlevel(int awardlevel) {
		this.awardlevel = awardlevel;
	}

	public int getVt() {
		return vt;
	}

	public void setVt(int vt) {
		this.vt = vt;
	}

	public String getTs() {
		return ts;
	}

	public void setTs(String ts) {
		this.ts = ts;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	public String getDigest() {
		return digestMD5();
	}
	
	private String digestMD5() {
		try {
			String digestMD5_Str = "" + action + userid + activityid
					+ awardlevel + vt + ts;
			java.security.MessageDigest md = java.security.MessageDigest
					.getInstance("MD5");
			md.update(digestMD5_Str.getBytes());
			byte[] b = md.digest();
			String tmp = "";
			String[] s = new String[16];
			int ii;
			for (int i = 0; i < 16; i++) {
				ii = b[i];
				if (b[i] < 0)
					ii = (int) (b[i] + 256);
				s[i] = Integer.toHexString(ii);
				if (s[i].length() == 1)
					s[i] = "0" + s[i];
				tmp += s[i];
			}
			return tmp.toUpperCase();
		} catch (Exception ex) {
			ex.printStackTrace();
			return null;
		}
	}
}
